package com.cedric.yixianpai.game.cards.Sects.swordCards.c_JinDan;

import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class PoQiJian extends SwordCard {
    private int decSE = 0;

    /**
     * title:破气剑
     * effect:-1SE 11/13/15攻 击伤:对方灵气减1/2/3
     */
    public PoQiJian(@Value("1") int lvl) {
        super("破气剑");
        this.setLevel(lvl);
        this.setPeriod(Period.JINDAN);
        this.setDescription("灵气-1 11/13/15攻 击伤:对方灵气减1/2/3");

        this.setSpiritNeed(1);
        if (1 == lvl) {
            this.setDamage(11);
            this.decSE = 1;
        } else if (2 == lvl) {
            this.setDamage(13);
            this.decSE = 2;
        } else if (3 == lvl) {
            this.setDamage(15);
            this.decSE = 3;
        } else {
            throw new RuntimeException("Card Level Error!");
        }
    }

    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        if (Sta1.spiritEnough(this.getSpiritNeed())) {
            if (Sta1.attack(Sta2, this.getDamage()) > 0) {
                Sta2.getPlayerBuff().decSpiritualEnergy(this.decSE);
            }
            Sta1.getPlayerBuff().clearSwordIntent();
        }
        return true;
    }
}
